package com.czxy.Service;

import com.czxy.dao.QianDao;
import com.czxy.domain.Qian;
import com.czxy.domain.User;
import java.util.Date;
import java.util.List;

/**
 * @author 嗨皮骚
 * @version v 1.0
 * @date 2019/5/9
 */
public class QianDaoService {
    QianDao dao=new QianDao();
    public void add(String uid, Date date) {
        Qian qian = new Qian(uid, date);
        dao.add(qian);
    }

    public List<Qian> findQianDaoByUid(String uid) {
        List<Qian> qians=dao.findQianDaoByUid(uid);
        return qians;
    }

    public int findQianDaoByUidDate(String uid, Date date) {
        Qian qian = new Qian(uid, date);
        List<Qian> qians=dao.findQianDaoByUidDate(qian);
        return qians.size();
    }

    public int userQianDaoNum(User loginUser) {
        int i = dao.userQianDaoNum(loginUser);
        return i;
    }
    public void upDatabaseDate() {
        Date date = new Date();
        int i = date.getMonth();
        int y = date.getYear()+1900;
        if (i==0){
            i=12;
            y=y-1;
        }

        dao.upDatabaseDate(y,i);
    }
}
